/*
 * Name     : MazewarNodeConfig.java
 * Author(s): Jill San Luis
 * Created  : Mar 14, 2011, 12:41:09 PM
 */
package mazewar.network;

import java.net.InetSocketAddress;

/**
 * The MazewarNodeConfig class
 *
 * @author  Jill San Luis
 */
public class MazewarNodeConfig {


    private static MazewarNodeConfig instance;

    private static final int BUFFER_LENGTH = 32;

    private static final int DEFAULT_NODE_PORT = 0;


    private InetSocketAddress local;

    public static final String DEFAULT_MULTICAST_GROUP = "224.2.2.3";
    private static final int DEFAULT_MULTICAST_PORT = 54327;
    private static final int DEFAULT_MULTICAST_TIMEOUT_SECONDS = 2;
    private InetSocketAddress multicast;

    /**
     * Creates a new instance of MazewarNodeConfig.
     */
    private MazewarNodeConfig() {
        local = new InetSocketAddress(DEFAULT_NODE_PORT);
        multicast = new InetSocketAddress(DEFAULT_MULTICAST_GROUP, DEFAULT_MULTICAST_PORT);
    }


    /**
     * DOCUMENT ME!
     *
     * @return  DOCUMENT ME!
     */
    public static synchronized MazewarNodeConfig getInstance() {

        if (instance == null) {
            instance = new MazewarNodeConfig();
        }

        return instance;
    }

    public int getBufferLength() {
        return BUFFER_LENGTH;
    }

    /**
     * DOCUMENT ME!
     *
     * @return  DOCUMENT ME!
     */
    public InetSocketAddress getNodeAddress() {
        return local;
    }

    /**
     * DOCUMENT ME!
     *
     * @return  DOCUMENT ME!
     */
    public InetSocketAddress getMulticastAddress() {
        return multicast;
    }

    /**
     * DOCUMENT ME!
     *
     * @return  DOCUMENT ME!
     */
    public String getDefaultMulticastGroup() {
        return DEFAULT_MULTICAST_GROUP;
    }

    /**
     * DOCUMENT ME!
     *
     * @return  DOCUMENT ME!
     */
    public int getDefaultNodePort() {
        return DEFAULT_NODE_PORT;
    }

    /**
     * DOCUMENT ME!
     *
     * @return  DOCUMENT ME!
     */
    public int getDefaultMulticastPort() {
        return DEFAULT_MULTICAST_PORT;
    }

    /**
     * DOCUMENT ME!
     *
     * @return  DOCUMENT ME!
     */
    public int getMulticastDefaultTTL() {
        return DEFAULT_MULTICAST_TIMEOUT_SECONDS;
    }
}
